function $$(o)
{
	return ( document.getElementById(o) == null ) ? document.getElementsByName(o)[0] : document.getElementById(o);
}

function ck(o)
{
	o = o||"";

	if("object" == typeof o)
	{
		if(o.value.length == 0)
		{
			return false;
		}
	}
	else
	{
		if(o.length == 0)
		{
			return false;
		}
	}
	return true;
}

function chooseAll(o)
{
	var src = o
	var p = "";
	while(p = o.parentNode)
	{
		if(p.tagName.toString().toUpperCase() == "TABLE")
		{
			break;
		}
		o = p;
	}
	var arr = p.getElementsByTagName("input");
	for(var i=0;i<arr.length;i++)
	{
		var tmp = arr[i];
		if(tmp.type.toString().toUpperCase() == "CHECKBOX" && tmp != src )
		{
			tmp.checked = src.checked;
		}
	}
}

function findParent(o,tag)
{
	var p = "";
	while(p = o.parentNode)
	{
		if(p.tagName.toString().toUpperCase() == tag.toString().toUpperCase())
		{
			return p;
		}
		o = p;
	}
	return "";
}

function formatUrl(url)
{
	return url+"?"+Math.random()
}
function euc(v)
{
	return encodeURIComponent(v);
}

function fixImgSize(o,maxWidth,maxHeight )
{
	maxWidth = maxWidth||200;
	maxHeight = maxHeight||200;
	var width = parseInt(o.width);
	var height = parseInt(o.height);
	var rate = width/height;
	if(rate>=1)
	{
		if(width>maxWidth)
		{
			o.width = maxWidth+"";
			o.height = parseInt(maxWidth/rate)+"";
		}
	}
	else
	{
		if(height>maxHeight)
		{
			o.height = maxHeight+"";
			o.width = parseInt(maxHeight*rate)+"";
		}
	}
}